package com.example.userclient.activity

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.userclient.Main.ClientInfoHolder
import com.example.userclient.R
import com.example.userclient.adapter.BuyBookListAdapter
import com.example.userclient.databinding.ActivityUserBuyBooksBinding

class UserBuyBooksActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val bind = DataBindingUtil.setContentView<ActivityUserBuyBooksBinding>(this, R.layout.activity_user_buy_books)
        for (i in ClientInfoHolder.userBuyBook!!){
            Log.i("UserSaleBooksActivity", i.addBook.bookOwner+ i.boss)
        }

        BuyBookListAdapter.dataSet = ClientInfoHolder.userBuyBook?.toTypedArray()
        bind.userBuyBooksList.adapter = BuyBookListAdapter
        bind!!.userBuyBooksList.layoutManager = LinearLayoutManager(this,RecyclerView.VERTICAL,false)

        bind.buyBack.setOnClickListener {
            this.finish()
        }
    }


    companion object{
        fun actionStart(context: Context){
            val intent = Intent(context, UserBuyBooksActivity::class.java)
            context.startActivity(intent)

        }
    }
}